/**********************************************************************
*
*   Copyright(C) 2021
*   FileName:
*   Version : V0.0.1
*   Date    : 2024-04-13
*   Author  : Song.YuLong@chipsbank
*   Description: 显示屏SPI接口驱动
*
*   Others:
*
*   Function List:
*   History      :
*
***********************************************************************/

#include "app_config.h"
#include "Type_def.h"

#ifndef __LCD_DRIVER_SPI_H__
#define __LCD_DRIVER_SPI_H__

/**
 * @brief SPI屏读写模式
 * @SPILCD_RW_CMD   命令
 * @SPILCD_RW_DATA  数据
*/
typedef enum {
    SPILCD_RW_CMD,
    SPILCD_RW_DATA
}spilcd_rw_mode_e;


#if ( (LCD_PANLE_MODULE == LCD_MODULE_UC1705X)||(LCD_PANLE_MODULE == LCD_MODULE_ST7567) ) // UC1705X LCM
#define PC_BOOST_ON					(0x1<<2) 				// Boost ON
#define PC_VOL_REGULAR_ON			(0x1<<1)				// Voltage Regular ON
#define PC_VOL_OLLOWER_ON  			(0x1)					// Voltage Follower ON
#define LCD_CMD_SETPC(val)			((0x28)|(val))			// Set Power Control
#define LCD_CMD_SETSL(sl)			((0x40)|(sl))			// Set Scroll Line
#define LCD_CMD_SW_REST				(0xE2)					//软件复位
#define LCD_CMD_SETPA(page)			((0xB0)+(page))					/* 1 0 1 1 , PA3, PA2, PA1, PA0		Page Address 0~8 */ 
#define LCD_CMD_SETCA_LSB(col)		((col)&(0x0F))					/* 0 0 0 0 , CA3, CA2, CA1, CA0		Column Address 0~131 */
#define LCD_CMD_SETCA_MSB(col)		((0x10)+(((col)&0xF0)>>(4)))	/* 0 0 0 1 , CA7, CA6, CA5, CA4		Column Address 0~131 */
#elif (LCD_PANLE_MODULE == LCD_MODULE_UC1611S)
#define PC_BOOST_ON					(0x1<<2) 				// Boost ON
#define PC_VOL_REGULAR_ON			(0x1<<1)				// Voltage Regular ON
#define PC_VOL_OLLOWER_ON  			(0x1)					// Voltage Follower ON
#define LCD_CMD_SETPC(val)			((0x28)|(val))			// Set Power Control
#define LCD_CMD_SETSL(sl)			((0x40)|(sl))			// Set Scroll Line

#define LCD_CMD_SW_REST				(0xE2)					//软件复位
#define LCD_CMD_SETPA_LSB(page)		((0x60)|((page)&(0x0F)))		/* 0 0 0 0 , PA3, PA2, PA1, PA0		Page Address 0~20 */
#define LCD_CMD_SETPA_MSB(page)		((0x70)+(((page)&0x70)>>(4)))	/* 0 0 0 1 , XXX, PA6, PA5, PA4		Page Address 0~20 */
#define LCD_CMD_SETCA_LSB(column)	((column)&(0x0F))				/* 0 0 0 0 , CA3, CA2, CA1, CA0		Column Address 0~255 */
#define LCD_CMD_SETCA_MSB(column)	((0x01)+(((column)&0xF0)>>(4)))	/* 0 0 0 1 , CA7, CA6, CA5, CA4		Column Address 0~255 */

#endif


u8 spilcd_spi_write(u8 tdata, spilcd_rw_mode_e mode);

void spilcd_set_window(int x0, int y0, int x1, int y1);

void spilcd_spi_init(void);

void spilcd_spi_deinit(void);

#endif
